<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="css/pintuer.css">
<link rel="stylesheet" href="css/admin.css">
<script src="js/jquery.js"></script>
<script src="js/pintuer.js"></script>
</head>
<body>
	<#if newList?exists>
	<div class="panel admin-panel">
		<div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>新闻列表</strong></div>
		<table class="table table-hover text-center">
	      <tr>
	        <th width="120">ID</th>
	        <th>标题</th>       
	        <th>内容</th>
	         <th width="120">更新时间</th>
	        <th>操作</th>       
	      </tr>
	      	<#list newList as homeNews>
	        <tr>
	          <td>${homeNews.id}</td>
	          <td style="width: 20%">${homeNews.title}</td>
	          <td style="width: 40%">${homeNews.getRemoveHtmlContent(25)}...</td>
	          <td><#if homeNews.updated??>${homeNews.updated?string('yyyy-MM-dd HH:mm:ss')}</#if></td>
	          <td>
		          <div class="button-group"> 
			          <a type="button" class="button border-main" href="/updateNews.html?id=${homeNews.id}"><span class="icon-edit"></span>修改</a>
			          <a class="button border-red" onClick="return confirm('确定要删除吗？');" href="/deleteNews.html?id=${homeNews.id}" onclick="return del(1)"><span class="icon-trash-o"></span> 删除</a> 
		          </div>
	          </td>
	        </tr>
	        </#list>
	        <tr>
		        <td colspan="8">
			        <div class="pagelist">
			        	<#if pageUtil.rainNum != 1>
				        <a href="/homeNews.html?index=0">首页</a> 
				        </#if>
			        	<#list pageUtil.rainbow as num >
			        	<#if num == pageUtil.rainNum>
				        <span class="current">${num}</span>
				        <#else>
				        <a href="/homeNews.html?index=${num-1}">${num}</a>
				        </#if>
				        </#list>
				        <#if pageUtil.rainNum lt pageUtil.totalPage>
				        <a href="/homeNews.html?index=${pageUtil.totalPage}">尾页</a> 
				        </#if>
			        </div>
		        </td>
		      </tr>
	    </table>
    </div>
    <br>
    </#if>
	<div class="panel admin-panel">
	  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>增加内容</strong></div>
	  <div class="body-content">
	    <form method="post" id="addFrom" class="form-x" enctype="multipart/form-data" action="/addHomeNews.html">  
	      <div class="form-group">
	        <div class="label">
	          <label>标题：</label>
	        </div>
	        <div class="field">
	          <input type="text" class="input w50" name="title" data-validate="required:请输入标题" />
	          <div class="tips"></div>
	        </div>
	      </div>
	      
	      <div class="form-group">
	        <div class="label">
	          <label>选择图片：</label>
	        </div>
	        <div class="field">
	          <input type="file" id="imgInput" class="input tips" style="width:25%; float:left;" data-toggle="hover" data-place="left" data-image="" name="uploadFile" value="新闻图片"/>
	          <div class="tips"></div>
	        </div>
	      </div>
	      <script>
	      $("#imgInput").change(function(){
	    	    $(this).attr("data-image",URL.createObjectURL($(this)[0].files[0]));
	    	    $(this).next().empty();
	    	    $(this).next().append("<img style='width:auto;padding: 7px; border-radius: 5px;border: 2px solid #ccc;max-width: 150px;max-height: 150px;margin-left: 100px;' src="+URL.createObjectURL($(this)[0].files[0])+">")
	    	});
	      </script>
	      <div class="form-group">
	        <div class="label">
	          <label>描述：</label>
	        </div>
	        <div class="field">
	        	<textarea id="editor_id" style="width:900px;height:500px;"></textarea>
	          	<script charset="utf-8" src="/kindeditor/kindeditor.js"></script>
	  			<script charset="utf-8" src="/kindeditor/lang/zh_CN.js"></script>
	          	<input type="hidden" class="input" name="content" />
	          <div class="tips"></div>
	        </div>
	      </div>
	      <div class="form-group">
	        <div class="label">
	          <label></label>
	        </div>
	        <div class="field">
	          <button id="addFromclick" class="button bg-main icon-check-square-o" type="submit"> 提交</button>
	        </div>
	      </div>
	    </form>
	  </div>
	</div>
<script>
	KindEditor.ready(function(K) {
        editor = K.create('#editor_id', {
       	//指定上传文件参数名称
     		filePostName  : "uploadFile",
     		//指定上传文件请求的url。
     		uploadJson : 'pic/upload',
     		//上传类型，分别为image、flash、media、file
     		dir : "image"
         });
	  });
	$(function(){
		$('#addFromclick').click(function(){
			$('#content').val(editor.html());
			$('#addFrom').submit();
			alert('添加成功');
		})
	})
</script>
</body>
</html>